import serial
import string
import binascii
import time
def read_file(file_name):
    fh = open(file_name, 'rb')
    f_read=fh.read()
    print(f_read)

s=serial.Serial('/dev/ttyUSB0',115200)
PS_DownChar=[0XEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X04,0X09,0X01,0X00,0X0F]
#read_file('fingerModel.txt')
fh = open('fingerModel.txt', 'rb')
f_read=fh.read()
print("---------------------------")
print(PS_DownChar)
s.write(PS_DownChar)
time.sleep(2)
number=s.inWaiting()
read= str(binascii.b2a_hex(s.read(number)))[2:-1]
print(read)
if read[19]=='0':
    print("指纹上传，接收后续数据包")
    s.write(f_read)
    time.sleep(2)
    number=s.inWaiting()
    read= str(binascii.b2a_hex(s.read(number)))[2:-1]
    print("!!!!!")
    print(read)
else:
    print("指纹上传失败")
